<template>
	<div>
		<span>{{ title }}</span>
		<Poptip v-model="visible" placement="bottom" width="200" word-wrap transfer>
	        <Icon type="ios-settings-outline" :size="14"></Icon>
	        <div class="spec-set-poptip" slot="content">
	        	<div class="title">{{ title }}：</div>
	        	<InputAmount
	        		v-if="type == 'money'"
	        		v-model="value"
	        	/>
	        	<InputNumber
	        		v-else
	        		v-model="value"
	        		:min="0"
	        		:step="1"
	        		:precision="precision"
	        		style="width: 100%;"
	        	/>
	        	<div class="btn-box">
	        		<Button type="primary" size="small" @click="handleClick">应用到全部列</Button>
	        	</div>
	        </div>
	    </Poptip>
	</div>
</template>

<script>
import InputAmount from '@/components/form/InputAmount.vue';
export default {
	name: 'setSpecPrice',
	components: {
		InputAmount
	},
	props: {
		title: String,
		type: {
			type: String,
			default: 'number'
		},
		precision: {
			type: Number,
			default: 0
		}
	},
	data() {
		return {
			visible: false,
			value: 0
		}
	},
	methods: {
		handleClick() {
			this.visible = false;
			this.$emit('change', this.value);
		}
	}
}
</script>